<template>
	<view class="cSD">
		<view class="cSDMain">
			<view class="cSDMainBox">
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						申请时间：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.createTime}}
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						故障配件名称：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.partsName}}
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						补助金额：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.payPrice}}元
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						鉴定市县：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.partsStorePerson}}  {{datMsg.partsStorePhone}}
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						产品规格：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.attributeName}}
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						安装凭证：
					</view>
					<view class="cSDMainBoxLiR">
						<image v-for="(ite,ind) in changeImgs(datMsg.installImages)" @click="previewImage(changeImgs(datMsg.installImages), ind)" :key="ind" class="cSDMainBoxLiRImg" :src=ite mode=""></image>
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						安装日期:
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.installTime}}
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						申请补助金信息:
					</view>
					<view class="cSDMainBoxLiR">
						<image v-for="(ite,ind) in changeImgs(datMsg.faultImages)" :key="ind" @click="previewImage(changeImgs(datMsg.faultImages), ind)"  class="cSDMainBoxLiRImg" :src=ite mode=""></image>
					</view>
				</view>
				<view class="cSDMainBoxLi">
					<view class="cSDMainBoxLiL">
						市县鉴定结果：
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.auditContent}}
					</view>
				</view>
			</view>
		</view>
		<view class="cSDMessage" v-if="datMsg.applyStatus == 4">
			<view class="cSDMessageHead">
				驳回原因：
			</view>
			<view class="cSDMessageContent" v-if="datMsg.agentContent">
				{{datMsg.agentContent}}
			</view>
			<view class="cSDMessageContent" v-else>
				无
			</view>
		</view>
		<view class="cSDBtn" v-if="datMsg.applyStatus == 1">
			<view class="cSDBtnL" @click="cli_bohui">
				驳回
			</view>
			<view class="cSDBtnR" @click="cli_tongguo">
				通过
			</view>
		</view>
		<uni-popup ref="popup" type="dialog">
			<view class="" v-if="show_dialog">
				<uni-popup-dialog mode="input" title="请输入驳回原因" :duration="2000" :before-close="true" @close="close" @confirm="confirm"></uni-popup-dialog>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				id: '',
				agentId: uni.getStorageSync('agentId'),
				datMsg: {},
				show_dialog: false
			}
		},
		onLoad(val) {
			if (val) {
				this.id = val.id
			}
		},
		mounted() {
			this.getQrCodeApplyDetails()
		},
		methods: {
			// 图片预览
			previewImage(item, index){
				console.log(item);
				// let lis = item.split()
				wx.previewImage({
				  current: index, // 当前显示图片的http链接
				  urls: item // 需要预览的图片http链接列表
				})
			},
			// 点击通过
			cli_tongguo () {
				this.saveQrCodeAppraisalByAgentId(3, '')
			},
			// 点击驳回
			cli_bohui () {
				this.$refs.popup.open()
				this.show_dialog = true
			},
			close () {
				this.$refs.popup.close()
				this.show_dialog = false
			},
			confirm (value) {
				if (value) {
					this.saveQrCodeAppraisalByAgentId(4, value)
					this.$refs.popup.close()
					this.show_dialog = false
				}else {
					uni.showToast({
						title:'请输入驳回原因',
						icon: 'none'
					})
				}
			},
			// 会长鉴定
			saveQrCodeAppraisalByAgentId (applyStatus,agentContent) {
				uni.request({
					url: allapi.saveQrCodeAppraisalByAgentId,
					data: {
						applyId: this.id,
						agentId: this.agentId,
						applyStatus: applyStatus,
						agentContent: agentContent
					},
					success: (res) => {
						console.log(res, '会长鉴定结果');
						uni.showToast({
							title: res.data.msg
						})
						
						setTimeout( ()=> {
							uni.navigateBack()
						}, 500)
					}
				})
			},
			// 获取详情
			getQrCodeApplyDetails () {
				uni.request({
					url: allapi.getQrCodeApplyDetails,
					data: {
						applyId: this.id
					},
					success: (res) => {
						console.log('获取详情',res);
						let dat = res.data.data
						this.datMsg = dat
					}
				})
			},
			changeImgs (val) {
				if (val) {
					return val.split('|')
				}else {
					return []
				}
			}
		}
	}
</script>

<style scoped>
	.cSD {
		position: absolute;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
	}
	.cSDMain {
		flex: 1;
		overflow: auto;
	}
	.cSDMainBox {
		margin: 24rpx;
		background: #FFFFFF;
		padding: 42rpx 24rpx;
		border-radius: 16rpx;
	}
	.cSDMainBoxLi {
		display: flex;
		margin-bottom: 44rpx;
	}
	.cSDMainBoxLiL {
		width: 204rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
		line-height: 40rpx;
	}
	.cSDMainBoxLiR {
		flex: 1;
		margin-left: 8rpx;
		font-size: 32rpx;
		color: #333333;
		line-height: 44rpx;
	}
	.cSDMainBoxLiRImg {
		width: 120rpx;
		height: 120rpx;
		background: #EEEEEE;
		border-radius: 8rpx;
		margin-right: 16rpx;
	}
	.cSDMessage {
		margin: 24rpx;
		padding: 48rpx 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
	}
	.cSDMessageHead {
		font-size: 28rpx;
		color: #666666;
		font-weight: 400;
	}
	.cSDMessageContent {
		margin-top: 24rpx;
		font-size: 28rpx;
		color: #333333;
		line-height: 56rpx;
	}
	.cSDBtn {
		height: 120rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 32rpx;
		padding-bottom: 68rpx;
	}
	.cSDBtnL {
		width: 296rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: #F3F5F6;
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #333333;
	}
	.cSDBtnR {
		width: 296rpx;
		height: 88rpx;
		line-height: 88rpx;
		background: linear-gradient(90deg, #2ACE52 0%, #1DC248 100%);
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
	}
</style>
